package com.h3c.controller;

import cn.hutool.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import cn.hutool.json.JSONObject;

@RestController
@RequestMapping("test")
public class TestController {
    private static Logger logger = LoggerFactory.getLogger(TestController.class);

    @PostMapping
    public JSONObject test01(@RequestBody JSONObject object) {

        JSONObject result = new JSONObject();

        try {
            String str = new JSONObject(new JSONArray(object.get("two")).get(1)).getStr("two3", "N/A");

            result.set("code", 200);
            result.set("msg", str);

            for (int i = 0; i < 100; i++) {
                logger.info(result.toString());
            }

            System.out.println("=========================");
            System.out.println("=========================");
            System.out.println("=========================");
            System.out.println("=========================");
            System.out.println("=========================");
        } catch (Exception e) {
            result.set("code", 500);
            result.set("msg", e.getMessage());
        }

        return result;
    }
}
